// ObserverMineGrid.h

#ifndef OBSERVERMINEGRID_H
#define OBSERVERMINEGRID_H

#include "Size.h"
#include "Point.h"
#include "MineGrid.h"
#include "Observer.h"

/**
* This is a MineGrid forged with a Observer, in order to
* utilize the observer pattern.
*/
class ObserverMineGrid : public Observer
{
public:
	/**
	* Constructor.
	*/
	ObserverMineGrid();

	/**
	* Constructor. Resizes the grid to the given size.
	*
	* @param size the new size.
	*/
	ObserverMineGrid( const Size& size );

	/**
	* Destructor.
	*/
	~ObserverMineGrid();

	/**
	* Resets the grid.
	*/
	void reset();

	/**
	* Resets the grid and resizes it to the
	* given size.
	*  
	* @param size the new size
	*/
	void reset( const Size& size );

	/**
	* Returns the size of the grid.
	*
	* @return Size the size of the grid.
	*/
	Size getGridSize() const;

	/**
	* Returns the elapsed time.
	*
	* @return int the currently elapsed time.
	*/
	int getElapsedTime() const;

	/**
	* Checks if the player is done with the game
	*
	* @return bool if the grid is finished.
	*/
	bool isDone() const;

	/**
	* Checks if the square is a swept mine.
	*
	* @param p the point to the square to check.
	* @return bool true if the square is a mine and swept.
	*/
	bool isSweptMine( const Point& p ) const;

	/**
	* Checks if the mine has been swept.
	*
	* @return bool if the mine has been swept.
	*/
	bool isSwept( const Point& p ) const;

	/**
	* Sweeps the mine.
	*/
	void sweepMine( const Point& p );

	/**
	* Checks if the mine has been flagged.
	*
	* @return bool if the mine has been flagged.
	*/
	bool isFlagged( const Point& p ) const;

	/**
	* Flags the mine.
	*/
	void flagMine( const Point& p );

	/**
	* Checks wether or not the square is a mine or not.
	*
	* @return bool if the square is a mine or not.
	*/
	bool isMine( const Point& p ) const;

	/**
	* Returns the status of the mine at the given point
	* in the grid.
	*
	* @return int the state of the mine.
	*/
	int getMineState( const Point& p ) const;

private:
	// The mine grid.
	MineGrid *grid;
};

#endif // OBSERVERMINEGRID_H
